package com.example.consumer;

import org.springframework.http.HttpRequest;
import org.springframework.http.client.ClientHttpRequestExecution;
import org.springframework.http.client.ClientHttpRequestInterceptor;
import org.springframework.http.client.ClientHttpResponse;

import java.io.IOException;

/**
 * @author weiZhiLin
 * @version 1.0
 * @date 2021/6/21 18:34
 */
public class MyInterceptor implements ClientHttpRequestInterceptor {
    @Override
    public ClientHttpResponse intercept(HttpRequest httpRequest, byte[] bytes, ClientHttpRequestExecution clientHttpRequestExecution) throws IOException {

        System.out.println("myInterceptor！！！");
        System.out.println(httpRequest.getURI());

        ClientHttpResponse response = clientHttpRequestExecution.execute(httpRequest, bytes);

        System.out.println(response.getHeaders());
        return response;
    }
}
